package com.neusoft.elm.controller;

// Unused import: java.util.List; // Not used in this controller
import javax.servlet.http.HttpServletRequest;
import com.neusoft.elm.po.User;
import com.neusoft.elm.service.UserService;
import com.neusoft.elm.service.impl.UserServiceImpl;

public class UserController {

    public Object getUserByIdByPass(HttpServletRequest request) throws Exception {
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        UserService service = new UserServiceImpl();
        User user = service.getUserByIdByPass(userId, password);
        return user;
    }

    public Object getUserById(HttpServletRequest request) throws Exception {
        String userId = request.getParameter("userId");
        UserService service = new UserServiceImpl();
        int result = service.getUserById(userId);
        return result;
    }

    public Object saveUser(HttpServletRequest request) throws Exception {
        User user = new User();
        user.setUserId(request.getParameter("userId"));
        user.setPassword(request.getParameter("password"));
        user.setUserName(request.getParameter("userName"));
        user.setUserSex(Integer.valueOf(request.getParameter("userSex")));
        // userImg is not set from request parameters in the API doc (2.3.6.3)
        // It might be set to a default value or handled differently.
        // For now, I will leave it as null or default based on POJO.
        UserService service = new UserServiceImpl();
        int result = service.saveUser(user);
        return result;
    }
}
